package edu.ucsd.ccdb.tagPopup.dataType;

import java.sql.SQLException;
import javax.swing.BoxLayout;
import javax.swing.JLabel;
import javax.swing.JPanel;

import edu.ucsd.ccdb.generalDataType.TagDataValue;
import edu.ucsd.irods.IRODSFileString;
import edu.ucsd.irods.SQLDBQuery;

public class CCDBTagElementDisplay extends TagElementDisplay {
	
	/* DATA FROM SUPER
	protected JButton deleleButton;
	
	// identifiers 
	protected long MPID; 
	protected IRODSFileString file;
	protected JPanel source;
	protected String username;
	*/
	
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private TagDataValue dataValue;
	
	public CCDBTagElementDisplay( String username, JPanel source, Integer MPID, IRODSFileString file, TagDataValue dataValue ) {
		
		super( username, source, MPID, file);	
		this.dataValue = dataValue;
		
		setLayout(new BoxLayout(this, BoxLayout.X_AXIS));
		
		add (deleleButton);
		add ( new JLabel (dataValue.toString() ) );
	
		setAlignmentX(LEFT_ALIGNMENT);
	}

	@Override		
	public void deleteData() {
		try {
			
			SQLDBQuery.removeTagCCDB(MPID, file, dataValue.getData() );
		} 
		catch (SQLException e) {
			e.printStackTrace();
		}
	}
}
